

Display_one_information proc far   
; 函数：打印单个学生的成绩数据
; 参数：ds:si 要打印数据的位置
; 无返回
; 打印格式：  name(14byte) (spaces*2) ID(12byte) (spaces*2) (score + space)*16 (sapce * 2) (course design score) (space *2) (finial score)
    
    push bp
    mov bp,sp
    push ds
    push si
    push ax
    push bx
    push cx
    push dx
    push es
    push di



    dispmsg one_space
    ; 将转换的字符暂时写在缓存区中
    mov_esdi_to_cache_area
    mov dx,20h ; dx存储空格字符

    ; 写入学生姓名

    mov cx,10h
    xor bx,bx
Display_one_information_name_cycle:
    mov al,ds:[si+bx]
    mov es:[di+bx],al
    inc bx
    loop Display_one_information_name_cycle
    

;写入空格
    xor bx,bx
Display_one_information_name_write_space:
    inc bx
    cmp bx,12h
    ja Display_one_information_ID
    mov ax,es:[di+bx]
    cmp ax,00h
    jnz Display_one_information_name_write_space
    mov es:[di+bx],dl
    jmp Display_one_information_name_write_space





Display_one_information_ID:
    ; 写入学生学号
    add si,010h
    mov di,012h
    mov cx,0Ch
    xor bx,bx
Display_one_information_ID_cycle:
    mov al,ds:[si+bx]
    mov es:[di+bx],al
    inc bx
    loop Display_one_information_ID_cycle

;写入空格
    xor bx,bx
Display_one_information_ID_write_space:
    inc bx
    cmp bx,0Ch
    ja Display_one_information_ID_done
    mov ax,es:[di+bx]
    cmp ax,00h
    jnz Display_one_information_ID_write_space
    mov es:[di+bx],dl
    jmp Display_one_information_ID_write_space


Display_one_information_ID_done:
    mov dl,'$'
    mov es:[di+bx],dl


    ; 输出 姓名和学号
    mov_dssi_to_cache_area
    mov dx,si
    mov ah, 9
    int 21h
    ; 清除缓存
    clear_area_ds _48 



    ;输出分数
    mov ax,ss:[bp-2]
    mov ds,ax
    mov si,ss:[bp-4]
    add si,1Ch

    mov cx,10h
    xor bx,bx
Display_one_information_score_cycle:
    push cx
    xor ax,ax
    mov al,ds:[si+bx]
    inc bx
    call far ptr display_ax_dec
    mov cx,4h
    sub cx,ax
Display_one_information_score_display_space:
    dispmsg one_space
    loop Display_one_information_score_display_space
    pop cx
    loop Display_one_information_score_cycle

    dispmsg ten_space
    xor ax,ax
    add bx,1h
    mov al,ds:[si+bx]
    call far ptr display_ax_dec

    dispmsg ten_space
    dispmsg four_space

    xor ax,ax
    add bx,2h
    mov al,ds:[si+bx]
    call far ptr display_ax_dec

    dispmsg next_row
    pop di
    pop ax
    mov es,ax
    pop dx
    pop cx
    pop bx
    pop ax
    pop si
    pop ax
    mov ds,ax
    pop bp
    retf

Display_one_information endp


;================================================================

Display_all_information proc far   
    dispmsg Talbe_titles
    dispmsg next_row 
; 函数： 打印出data段中所有的学生信息
; 参数 ax 页数 第一页为0,每页显示20行信息
    push ax
    mov ax,ss:[bp+16h]
    mov dx,ax   ; dx表示当前有多少条信息

    pop ax
    push ax
    mov bl,14h
    mul bl     ; ax表示从第几条信息开始打印
    mov bx,ax
    cmp ax,dx
    ja Display_all_information_done  ;开始打印位置大于信息数量，直接结束程序

    mov ax,data
    mov ds,ax
    lea si,data_start


    mov cx,14h

    ; bx: 起始地址
    



Display_all_information_cycle:
    mov ax,bx
    call far ptr Get_pointers
    mov si,ax
    cmp bx,dx   ;  bx超过dx时退出
    jnb Display_all_information_done

    cmp cx,0h   ; 输出超过20条时退出
    jz Display_all_information_done


    call far ptr Display_one_information

    dec cx
    add bx,1
    jmp Display_all_information_cycle


Display_all_information_done:

    dispmsg Display_all_information_page_left
    pop ax
    call far ptr display_ax_dec
    dispmsg Display_all_information_page_right
    dispmsg next_row
    retf


Display_all_information endp


;================================================================

Display_all_information_Top proc far  

    dispmsg Display_all_information_input_page

    mov_dssi_to_cache_area
    clear_area_ds _2
    mov ax,0201h    ; 接收最大1字节的数字字符
    call far ptr Get_input
    xor ah,ah
    mov al,ds:[si]
    ; 将输入的字符串转换为数值
    mov ax,2h
    call far ptr Convert_str_to_value 
    ; 以该数值为参数调用Display_all_information
    call far ptr Display_all_information
    clear_area_ds _2  

    retf
Display_all_information_Top endp
